package zy.blue7.gui.netty.package1.simple;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.CharsetUtil;

/**
 * @Author: blue7
 * @Date: 2022/2/25 19:57
 * @Version 1.0
 * @Description
 * https://blog.csdn.net/mffandxx/article/details/51923651
 */
public class TimeServerHandler extends SimpleChannelInboundHandler<Object> {
    static int  count=0;
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, Object msg) throws Exception {

        ByteBuf buf= (ByteBuf) msg;

        System.out.println(buf.toString(CharsetUtil.UTF_8)+" --- " );

        channelHandlerContext.writeAndFlush(Unpooled.copiedBuffer("this is a message "+count++,CharsetUtil.UTF_8));
    }
}
